<?php

class Backend_pages extends Controller{
	
	function Backend_pages(){
		parent::Controller();
		
		$this->load->model(array('m_products','m_users'));
		$this->load->library(array('pagination','form_validation'));
		
	}
	
	function admin_profiles(){
		
		$data['title'] = 'Admin Profile';
		$this->load->view('pages_admin/index',$data);		
	}
	// ===========Backend pages=========song
	// register user member in website
    function addmember() {

        $this->form_validation->set_rules('gender', 'Gender', 'trim|required');
        $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_alpha_numeric|min_length[6]|xss_clean|strtolower|callback_username_not_exists');
        $this->form_validation->set_rules('pass', 'Password', 'trim|required|alpha_alpha_numeric|min_length[6]|matches[con_pass]|xss_clean');
        $this->form_validation->set_rules('con_pass', 'Confirm_password', 'trim|required|alpha_alpha_numeric|min_length[6]');
        $this->form_validation->set_rules('phone', 'phone', 'trim|required|alpha_alpha_numeric|min_length[9]|max_lenght[10]');


        if ($this->form_validation->run() == FALSE) {
            //hasn't been run or there are validation errors
            $data['title'] = 'Add memeber';
            // $data['menu'] = $this->menu->show_menu();
			//$data['sli_pro'] = $this->m_products->sl_pro();// product on slide bar
			
            $this->load->view('pages_admin/index', $data);
        } else {
            $result['reg'] = $this->m_users->register();

            if ($result) {
                redirect('backend_pages/member');
            } else {
                echo 'error';
            }
        }
    }

    // fun username not exists in record.....
    function username_not_exists($username) {
        $this->form_validation->set_message('username_not_exists', $this->input->post('username') . ' already exists.<br />
 Please choose a different from ' . $this->input->post('username') . '!');
        //redirect('con_login/login');
        if ($this->m_users->checkexist($username)) {
            return false;
        } else {
            return true;
        }
    }

    // ============ End check username exist ========***
	//fun call member pages into master pages....
	function member(){
		
		$this->session->set_userdata('count_member',$this->db->count_all('tbl_user'));
		
		$config['base_url'] = site_url('backend_pages/member');
		$config['total_rows'] = $this->db->count_all('tbl_user');;
		$config['per_page'] = 7;
		$config["uri_segment"] = 3;
		$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
		$this->pagination->initialize($config);
		
		$data['pages'] = $this->pagination->create_links();
		$data['title'] = 'All Members';
		$data['member'] = $this->m_users->view_account($config['per_page'],$page);
		$this->load->view('pages_admin/index',$data);			
	}
	// select all members to update ====by kimsong.san
	function admin_update_account(){
		
        
        $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_alpha_numeric|min_length[6]|xss_clean|strtolower');
        $this->form_validation->set_rules('phone', 'phone', 'trim|required|alpha_alpha_numeric|min_length[9]|max_lenght[10]');

        if ($this->form_validation->run() == FALSE) {
            //hasn't been run or there are validation errors
            $data['title'] = 'Update account ';
			//$data['sli_pro'] = $this->m_products->sl_pro();// product on slide bar
            //$data['member'] = $this->m_users->selet_edit_member();
			$data['member'] = $this->m_users->selet_edit_member();
			
            $this->load->view('pages_admin/index', $data);
        } else {
            $data['account'] = $this->m_users->admin_update_account();
            if ($data['account'] > 0) {

                redirect('backend_pages/member');
            }
        }
	}
	
	//========End select all members =======
	
	//fun to delete users members , data from db .......
	function admin_delete_member(){
		$id = $this->uri->segment(3);
			if((int)$id > 0){
				$oldrow = array('user_id' => $id);
				$this->m_users->admin_delete_member($oldrow);
				redirect('backend_pages/member');
			}   
		}
	
	
	
	
	//fun call member pages into master pages....
		function addmenu(){
			
			$data['title'] = "Add Menu";
			$this->load->view('pages_admin/index',$data);		
		}
	//fun call member pages into master pages....
		function allmenu(){
	
			$config['base_url'] = 'http://localhost/groups-developer/backend_pages/allmenu';
			$config['total_rows'] = $this->db->count_all('tbl_menu');;
			$config['per_page'] = 10;
			$config["uri_segment"] = 3;
			 $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
			$this->pagination->initialize($config);
			
			$data['pages'] = $this->pagination->create_links();
			
			$data['title'] = "All Menu";
			$this->load->model('m_menu');
			$data['admin_menu'] = $this->m_menu->select_menu($config['per_page'],$page);
			$this->load->view('pages_admin/index',$data);		
		}
		
     /* upload images users login with resize images.........

     * ********************** */

    private $datapro = array(
        'dir' => array(
            'original' => 'assets/uploads/original/',
            'thumb' => 'assets/uploads/thumbs/'
        ),
        'total' => 0,
        'images' => array(),
        'error' => ''
    );

    public function addproducts($start = 0) {
        if ($this->input->post('btn_upload')) {
            $this->uploadproduct();
        }


        $c_paginate['base_url'] = site_url('backend_pages/addproducts');
        $c_paginate['per_page'] = '9';
        $finish = $start + $c_paginate['per_page'];

        if (is_dir($this->datapro['dir']['thumb'])) {
            $i = 0;
            if ($dh = opendir($this->datapro['dir']['thumb'])) {
                while (($file = readdir($dh)) !== false) {
                    // get file extension
                    $ext = strrev(strstr(strrev($file), ".", TRUE));
                    if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png') {
                        if ($start <= $this->datapro['total'] && $this->datapro['total'] < $finish) {
                            $this->datapro['images'][$i]['thumb'] = $file;
                            $this->datapro['images'][$i]['original'] = str_replace('thumb_', '', $file);
                            $i++;
                        }
                        $this->datapro['total']++;
                    }
                }
                closedir($dh);
            }
        }


        $c_paginate['total_rows'] = $this->datapro['total'];
        $this->pagination->initialize($c_paginate);
        $data = $this->datapro;
        //$data['menu'] = $this->menu->show_menu();
      
        $data['title'] = 'Add products';
		
        $this->load->view('pages_admin/index', $data);
    }

    private function uploadproduct() {
		
        $c_upload['upload_path'] = $this->datapro['dir']['original'];
        $c_upload['allowed_types'] = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
        $c_upload['max_size'] = '500';
        $c_upload['max_width'] = '1600';
        $c_upload['max_height'] = '1200';
        $c_upload['remove_spaces'] = TRUE;

        $this->load->library('upload', $c_upload);

        if ($this->upload->do_upload()) {

            $img = $this->upload->data();

            // create thumbnail
            $new_image = $this->datapro['dir']['thumb'] . 'thumb_' . $img['file_name'];

            $c_img_lib = array(
                'image_library' => 'gd2',
                'source_image' => $img['full_path'],
                'maintain_ratio' => TRUE,
                'width' => 100,
                'height' => 100,
                'new_image' => $new_image
            );

            $this->load->library('image_lib', $c_img_lib);
            $this->image_lib->resize();

            $img = $this->upload->data();
            //$this->session->set_userdata('Adver_Size',$img['image_size_str']);
            $this->session->set_userdata('pro_img', $img['file_name']);

            //$this->load->model('M_addproduct');
            $data['product'] = $this->m_products->addproduct();
            if ($data['product'] > 0) {
                redirect('backend_pages/allproducts');
            }else{
				redirect('backend_pages/addproducts/error');	
			}
        } else {
            $this->data['error'] = $this->upload->display_errors();
        }
    }

    public function delete($ori_img) {
		
        unlink($this->datapro['dir']['original'] . $ori_img);
        unlink($this->datapro['dir']['thumb'] . 'thumb_' . $ori_img);

       // $this->load->model('m_addproduct');
        $id = $this->uri->segment(3);
        $oldrow = array('pro_img' => $id);
        $this->m_products->del_pro($oldrow);
		
        redirect('backend_pages/allproducts');
    }

    // ************End the upload user product into advertising ***********
	
    // end fun update_profile users...........
	 // end fun update_profile users...........
		
		function allproducts(){

			$config['base_url'] = site_url('backend_pages/allproducts');
			$config['total_rows'] = $this->db->count_all('tbl_product');;
			$config['per_page'] = 7;
			$config["uri_segment"] = 3;
			$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
			$this->pagination->initialize($config);
			
			$data['pages'] = $this->pagination->create_links();
			
			$data['backend_prolist'] = $this->m_products->view_product($config['per_page'],$page);
			$data['title'] = 'Backend products page';
			
			$this->load->view('pages_admin/index',$data);
		}
	//********fun to delete*********//
	
	// edit products pages in backend =========
	
	function sel_upateproduct(){//selup_product
		if(!$this->input->post('btn_upload')){
				$data['title'] = "Form update product";
				$data['upproduct'] = $this->m_products->sel_up();
				
				$this->load->view('pages_admin/index',$data);
				}else{
				
					$data['up_prodata'] = $this->m_products->m_update_product();
					if ($data['up_prodata'] > 0) {
						
						redirect('backend_pages/allproducts');
					}
				}
	}
	
	/************====>>>>>>> upadte product users login by administor <<<<<<<<<<< =========**********/
	
 	/***********by Rina.Pov ****************
	* update images that we advertis in the website
 	***********************/
		
		 private $up_pro = array(
        'dir' => array(
            'original' => 'assets/uploads/original/',
            'thumb' => 'assets/uploads/thumbs/'
        ),
        'total' => 0,
        'images' => array(),
        'error' => ''
    );

    public function change_product($start = 0) {
		
        if ($this->input->post('btn_upload')) {
            $this->update_pro_upload();
        }

        $this->load->library('pagination');

        $c_paginate['base_url'] = site_url('backend_pages/addproducts');
        $c_paginate['per_page'] = '9';
        $finish = $start + $c_paginate['per_page'];

        if (is_dir($this->datapro['dir']['thumb'])) {
            $i = 0;
            if ($dh = opendir($this->up_pro['dir']['thumb'])) {
                while (($file = readdir($dh)) !== false) {
                    // get file extension
                    $ext = strrev(strstr(strrev($file), ".", TRUE));
                    if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png') {
                        if ($start <= $this->datapro['total'] && $this->up_pro['total'] < $finish) {
                            $this->up_pro['images'][$i]['thumb'] = $file;
                            $this->up_pro['images'][$i]['original'] = str_replace('thumb_', '', $file);
                            $i++;
                        }
                        $this->up_pro['total']++;
                    }
                }
                closedir($dh);
            }
        }


        $c_paginate['total_rows'] = $this->up_pro['total'];
        $this->pagination->initialize($c_paginate);
        $data = $this->up_pro;
        //$data['menu'] = $this->menu->show_menu();
     
        $data['title'] = 'Update products';
		
        $this->load->view('pages_admin/index', $data);
    }

    private function update_pro_upload() {
		
        $c_upload['upload_path'] = $this->up_pro['dir']['original'];
        $c_upload['allowed_types'] = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
        $c_upload['max_size'] = '500';
        $c_upload['max_width'] = '1600';
        $c_upload['max_height'] = '1200';
        $c_upload['remove_spaces'] = TRUE;

        $this->load->library('upload', $c_upload);

        if ($this->upload->do_upload()) {

            $img = $this->upload->data();

            // create thumbnail
            $new_image = $this->up_pro['dir']['thumb'] . 'thumb_' . $img['file_name'];

            $c_img_lib = array(
                'image_library' => 'gd2',
                'source_image' => $img['full_path'],
                'maintain_ratio' => TRUE,
                'width' => 100,
                'height' => 100,
                'new_image' => $new_image
            );

            $this->load->library('image_lib', $c_img_lib);
            $this->image_lib->resize();

            $img = $this->upload->data();
            $this->session->set_userdata('pro_img', $img['file_name']);
            $data['product'] = $this->m_products->m_change_pro();
            if ($data['product'] > 0) {
                redirect('backend_pages/deluppro');
            }else{
				redirect('backend_pages/editproducts/error');	
			}
        } else {
            $this->data['error'] = $this->upload->display_errors();
        }
    }
	/************====>>>>>>>End upadte product users login by administor <<<<<<<<<<< =========**********/
	/*********============Delete img from folder by unlink <it old variable to add products  =>>datapro >==========******/
	function deluppro(){
				$ori_img = $this->session->userdata('getImg');
				
				unlink($this->datapro['dir']['original'].$ori_img);
        		unlink($this->datapro['dir']['thumb'].'thumb_'.$ori_img);
				
				redirect('backend_pages/allproducts');
		}
	/*******End Delete img from folder **********/
	/*********============Delete img from folder by unlink <it old variable to add products  =>>datapro >==========******/
	// fun delete db---
	public function del_pro($ori_img) {
		
        unlink($this->data['dir']['original'] . $ori_img);
        unlink($this->data['dir']['thumb'] . 'thumb_' . $ori_img);

        $id = $this->uri->segment(3);
        $oldrow = array('pro_img' => $id);
        $this->m_products->del_news($oldrow);
		
        redirect('pages/allproducts');
    }
	/*******End Delete img from folder **********/
	// fun to update menu .....
	function editmenu(){
		$id = $this->uri->segment(3);
		if((int)$id > 0){
			$oldrow = array('menu_id' => $id);
	        $this->load->model('m_menu');
			$data['menu'] = $this->m_menu->update_menu($oldrow);	
			$data['title'] = 'Update Menu';
			$this->load->view('pages_admin/index',$data);	
			//redirect('backend_pages/editmenu');
		}   
	}
	// just test update version ========
	
	// all Advertising ============>>>>by kimsong<<<<=====
	function allItem(){

		$config['base_url'] = site_url('backend_pages/allItem');
		$config['total_rows'] = $this->db->count_all('tbl_media');;
		$config['per_page'] = 7;
		$config["uri_segment"] = 3;
		$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
		$this->pagination->initialize($config);
		
		$data['pages'] = $this->pagination->create_links();
		
		$data['adver'] = $this->m_products->alladver($config['per_page'],$page);
		$data['title'] = 'Backend All Advertis page';
		$this->load->view('pages_admin/index',$data);		
	}
		
	/* ************************
		*upload images Advertising with resize images by Kimsong.san .........
		
		************************
		
		 private $data = array(
        'dir' => array(
            'original' => 'advertising/uploads/original/',
            'thumb' => 'advertising/uploads/thumbs/'
        ),
        'total' => 0,
        'images' => array(),
        'error' => ''
    	);

	public function addItem($start = 0)
	{
        if ($this->input->post('btn_upload_adver')) {
            $this->upload();
        }

        $this->load->library('pagination');

        $c_paginate['base_url'] = site_url('backend_pages/addItem');
        $c_paginate['per_page'] = '9';
        $finish = $start + $c_paginate['per_page'];
        
        if (is_dir($this->data['dir']['thumb']))
        {
            $i = 0;
            if ($dh = opendir($this->data['dir']['thumb'])) {
                while (($file = readdir($dh)) !== false) {
                    // get file extension
                    $ext = strrev(strstr(strrev($file), ".", TRUE));
                    if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png'|| $ext == 'gif') {
                        if ($start <= $this->data['total'] && $this->data['total'] < $finish) {
                            $this->data['images'][$i]['thumb'] = $file;
                            $this->data['images'][$i]['original'] = str_replace('thumb_', '', $file);
                            $i++;
                        }
                        $this->data['total']++;
                    }
                }
                closedir($dh);
            }
        }
		
		//form validation the input file not value or wrong......
		$this->load->library('form_validation');
		$this->form_validation->set_rules('adverName', 'Advertis name', 'required');
		$this->form_validation->set_rules('adverUrl', 'Advertis URL', 'required');
		$this->form_validation->set_rules('adverPos', 'Advertis Position ', 'required');
		// End form validation........
		if($this->form_validation->run() == FALSE){
		
        $c_paginate['total_rows'] = $this->data['total'];
        $this->pagination->initialize($c_paginate);
		$data = $this->data;
		$data['title'] = 'Add Advertising';
		$this->load->view('pages_admin/index', $data);
		}
		
	}

    private function upload()
    {
		//form validation the input file not value or wrong......
		$this->load->library('form_validation');
		$this->form_validation->set_rules('adverName', 'Advertis name', 'required');
		$this->form_validation->set_rules('adverUrl', 'Advertis URL', 'required');
		$this->form_validation->set_rules('adverPos', 'Advertis Position ', 'required');
		// End form validation........
		if($this->form_validation->run() == FALSE){
       
		$data = $this->data;
		$data['title'] = 'Add Advertising';
		$this->load->view('pages_admin/index', $data);
		}else{
				$c_upload['upload_path']    = $this->data['dir']['original'];
				$c_upload['allowed_types']  = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
				$c_upload['max_size']       = '700';
				$c_upload['max_width']      = '1600';
				$c_upload['max_height']     = '1200';
				$c_upload['remove_spaces']  = TRUE;
		
				$this->load->library('upload', $c_upload);
				
				if ($this->upload->do_upload()) {
					
					$img = $this->upload->data();
					if($this->input->post('adverPos')== 5){
					// // banner big top one=====
					
					// create thumbnail
					$new_image = $this->data['dir']['thumb'].'thumb_'.$img['file_name'];
					
					$c_img_lib = array(
						'image_library'     => 'gd2',
						'source_image'      => $img['full_path'],
						'maintain_ratio'    => TRUE,
						'width'             => 600,
						'height'            => 100,
						'new_image'         => $new_image
					);
					
					$this->load->library('image_lib', $c_img_lib);
					$this->image_lib->resize();
					}else if($this->input->post('adverPos') == 3 || $this->input->post('adverPos') == 4){    // banner big riht and left
					
					
					// create thumbnail
					$new_image = $this->data['dir']['thumb'].'thumb_'.$img['file_name'];
					
					$c_img_lib = array(
						'image_library'     => 'gd2',
						'source_image'      => $img['full_path'],
						'maintain_ratio'    => TRUE,
						'width'             => 300,
						'height'            => 4000,
						'new_image'         => $new_image
					);
					
					$this->load->library('image_lib', $c_img_lib);
					$this->image_lib->resize();
					}else{
						// banner small riht and left
						// create thumbnail
					$new_image = $this->data['dir']['thumb'].'thumb_'.$img['file_name'];
					
					$c_img_lib = array(
						'image_library'     => 'gd2',
						'source_image'      => $img['full_path'],
						'maintain_ratio'    => TRUE,
						'width'             => 500,
						'height'            => 100,
						'new_image'         => $new_image
					);
					
					$this->load->library('image_lib', $c_img_lib);
					$this->image_lib->resize();
						
						
					}
					
					$img = $this->upload->data();
					$this->session->set_userdata('Adver_img',$img['file_name']);
					$this->session->set_userdata('Adver_size',$img['image_size_str']);
					
						$data['adver'] = $this->m_addproduct->addAdvertis();
						if($data['adver']>0){
							redirect('backend_pages/allItem');
						}
					
					
				} else {
					$this->data['error'] = $this->upload->display_errors();
				}
		}
		
    }
	
	
	// fun to delete images Advertising ***********
	
	public function delete_adver($ori_img)
    {
        unlink($this->data['dir']['original'].$ori_img);
        unlink($this->data['dir']['thumb'].'thumb_'.$ori_img);
		
			$id = $this->uri->segment(3);
				$oldrow = array('Adver_img' => $id);
				$this->m_addproduct->del_adver($oldrow);
        redirect('backend_pages/allItem');
    }
	 
	// ************* End Add Advertising *********/
	//start change photo of users statu
	function addItem()
	{
		$config['upload_path'] = './advertising/uploads/';
		$config['allowed_types'] = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
		$config['max_size']	= '100';
		$config['max_width']  = '1000';
		$config['max_height']  = '1000';

		$this->load->library('upload', $config);

		if ( ! $this->upload->do_upload())
		{
			$error = array('error' => $this->upload->display_errors());
            $error['title'] = 'Backend Add Advertis images';
                        //redirect("backend_pages/addItem/error");
			$this->load->view('pages_admin/index', $error);
		}
		else
		{
			//$data = array('upload_data' => $this->upload->data());
			$upload_data = $this->upload->data();
			
			//$upload_data['file_name'];
			$this->session->set_userdata('adver_img',$upload_data['file_name']);
			$ch['adver'] = $this->m_products->add_adver();
			if($ch['adver'] > 0){
				redirect("backend_pages/allItem");
			}else{
				redirect("pages/user_profile/default");
			}
			
		}
	}
	
   
 //===========================this is function add new user and validate form-==========================//
		function sel_upateItem(){
			$config['upload_path'] = './advertising/uploads/';
			$config['allowed_types'] = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
			$config['max_size']	= '100';
			$config['max_width']  = '1000';
			$config['max_height']  = '1000';
	
			$this->load->library('upload', $config);
	
			if ( ! $this->upload->do_upload())
			{
				$error = array('error' => $this->upload->display_errors());
				$data['title'] = 'Update Advertising images';
				$data['adver_up'] = $this->m_products->selItem_update();
				$this->load->view('pages_admin/index',$data);
			}
			else
			{
				//$data = array('upload_data' => $this->upload->data());
				$upload_data = $this->upload->data();
				
				//$upload_data['file_name'];
				$this->session->set_userdata('adver_img',$upload_data['file_name']);
				$ch['adver'] = $this->m_products->update_adver();
				if($ch['adver'] > 0){
					redirect("backend_pages/delupItem");
				}else{
					redirect("backend_pages/sel_upateItem");
				}
				
			}
			
				
				
		}
 
 	/***********by Rina.Pov ****************
	* update images that we advertis in the website
 	***********************/
		
		function delupItem(){
				$ori_img = $this->session->userdata('getadvImg');
				
				unlink('./advertising/uploads/'.$ori_img);
				
				redirect('backend_pages/allItem');
		}
		
		 function delete_adver($ori_img)
			{
				unlink('./advertising/uploads/'.$ori_img);
					$id = $this->uri->segment(3);
						$oldrow = array('media_img' => $id);
						$this->m_products->del_adver($oldrow);
				redirect('backend_pages/allItem');
			}
		// func news management...
		function add_news_control(){
			$config['upload_path'] = './news/uploads/';
			$config['allowed_types'] = 'gif|jpg|jpeg|png|JPEG|JPG|PNG|x-png';
			$config['max_size']	= '100';
			$config['max_width']  = '1000';
			$config['max_height']  = '1000';
	
			$this->load->library('upload', $config);
	
			if ( ! $this->upload->do_upload())
			{
				$error = array('error' => $this->upload->display_errors());
				$error['title'] = 'Backend Add News management';
				$this->load->view('pages_admin/index', $error);
			}
			else
			{
				//$data = array('upload_data' => $this->upload->data());
				$upload_data = $this->upload->data();
				
				//$upload_data['file_name'];
				$this->session->set_userdata('news_img',$upload_data['file_name']);
				$ch['news'] = $this->m_products->add_news();
				if($ch['news'] > 0){
					redirect("backend_pages/all_news_control");
				}else{
					redirect("pages/user_profile/default");
				}
				
			}
		}
		// all Advertising ============>>>>by kimsong<<<<=====
		function all_news_control(){

		$config['base_url'] = site_url('backend_pages/all_news_control');
		$config['total_rows'] = $this->db->count_all('tbl_page');;
		$config['per_page'] = 7;
		$config["uri_segment"] = 3;
		$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
		$this->pagination->initialize($config);
		
		$data['pages'] = $this->pagination->create_links();
		
		$data['news'] = $this->m_products->allnews($config['per_page'],$page);
		$data['title'] = 'Backend All Advertis page';
		$this->load->view('pages_admin/index',$data);		
		}
		//fun delete news
		function delete_news($ori_img)
			{
				unlink('./news/uploads/'.$ori_img);
					$id = $this->uri->segment(3);
						$oldrow = array('page_img' => $id);
						$this->m_products->del_news($oldrow);
				redirect('backend_pages/all_news_control');
			}
		// fun set status products
		
		function setStatu(){
			$setsta['statu'] = $this->m_products->setstatu();
			if($setsta){
				redirect('backend_pages/allproducts');
			}else{
				
			}
		}
		// fun set status mem_statu
		
		function mem_statu(){
			$setsta['statu'] = $this->m_users->mem_statu();
			if($setsta){
				redirect('backend_pages/member');
			}else{
				
			}
		}
		
	
	